﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Dapper_Core.DAL.Impl
{
    public class SelectFieldHelper
    {
        /// <summary>
        /// 根据单据模板信息得到字段串
        /// </summary>
        /// <param name="voucherName">单据模板名称(例如预测单：intendSaleOrder)</param>
        /// <param name="detailsName">明细属性名称(例如预测单明细：intendSaleOrderDetails)</param>
        /// <returns></returns>
        public static string GetSelectField(string voucherName, string detailsName)
        {
            ISelectField selectField = SelectFieldFactory.GetInstance("DefaultSelectField");
            return selectField.GetSelectField(voucherName, detailsName);
        }

        /// <summary>
        /// 得到SelectField串
        /// </summary>
        /// <param name="key">索引号,具体规则可参加SelectFieldFactory类</param>
        /// <param name="dtoName">得到selectField的DTO的名称
        ///    例如:得到预测单明细对象的存货的selectField，该参数传递"IntendSaleOrderDetailDTO"
        /// </param>
        /// <param name="propertyName">对象类型的属性名称
        ///    例如：预测单明细上的存货，该参数为"Inventory"
        /// </param>
        /// <returns>逗号隔开的SelectField串</returns>
        public static string GetSelectField(string key, string dtoName, string propertyName)
        {
            ISelectField selectFieldHandler = SelectFieldFactory.GetInstance(key);
            return selectFieldHandler.GetSelectFieldEx(dtoName, propertyName);
        }

        /// <summary>
        /// 得到SelectField串
        /// </summary>
        /// <param name="key">索引号,具体规则可参加SelectFieldFactory类</param>
        /// <returns></returns>
        public static string GetSelectField(string key)
        {
            ISelectField selectFieldHandler = SelectFieldFactory.GetInstance(key);
            return selectFieldHandler.GetSelectField();
        }
    }
}
